/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package br.gov.cemaden.library.model.smp;

import br.gov.cemaden.library.model.BaseEntity;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import org.codehaus.jackson.annotate.JsonBackReference;

/**
 *
 * @author paulo.dias
 */
@Entity
@Table(name = "smp_load_average", schema = "smp")
@SequenceGenerator(name = "sequence", sequenceName = "smp.smp_load_average_sequence", schema = "smp")
@NamedQueries({
    @NamedQuery(name = "LoadAverage.findAll", query = "SELECT a FROM LoadAverage a ORDER BY a.id ASC"),
    @NamedQuery(name = "LoadAverage.findById", query = "SELECT a FROM LoadAverage a WHERE a.id = :id"),
    @NamedQuery(name = "LoadAverage.findByLoad1min", query = "SELECT a FROM LoadAverage a WHERE a.load1min = :load1min"),
    @NamedQuery(name = "LoadAverage.findByLoad5min", query = "SELECT a FROM LoadAverage a WHERE a.load5min = :load5min"),
    @NamedQuery(name = "LoadAverage.findByLoad15min", query = "SELECT a FROM LoadAverage a WHERE a.load15min = :load15min"),
    @NamedQuery(name = "LoadAverage.findByExecHardware", query = "SELECT a FROM LoadAverage a WHERE a.execHardware = :execHardware"),})
public class LoadAverage implements Serializable, BaseEntity {

    @Id
    @GeneratedValue(generator = "sequence", strategy = GenerationType.AUTO)
    @Column(name = "id_load_average", nullable = false, unique = true)
    private Long id;
    
    @Column(name = "load1min")
    private Double load1min;
    
    @Column(name = "load5min")
    private Double load5min;
    
    @Column(name = "load15min")
    private Double load15min;
    
    @OneToOne
    @JsonBackReference
    @JoinColumn(name = "id_exec_hardware", referencedColumnName = "id_exec_hardware", unique = true)
    private ExecHardware execHardware;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Double getLoad1min() {
        return load1min;
    }

    public void setLoad1min(Double load1min) {
        this.load1min = load1min;
    }

    public Double getLoad5min() {
        return load5min;
    }

    public void setLoad5min(Double load5min) {
        this.load5min = load5min;
    }

    public Double getLoad15min() {
        return load15min;
    }

    public void setLoad15min(Double load15min) {
        this.load15min = load15min;
    }

    public ExecHardware getExecHardware() {
        return execHardware;
    }

    public void setExecHardware(ExecHardware execHardware) {
        this.execHardware = execHardware;
    }

    @Override
    public int hashCode() {
        int hash = 3;
        hash = 61 * hash + (this.id != null ? this.id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final LoadAverage other = (LoadAverage) obj;
        if (this.id != other.id && (this.id == null || !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "LoadAverage{" + "id=" + id + ", load1min=" + load1min + ", load5min=" + load5min + ", load15min=" + load15min + ", execHardware=" + execHardware + '}';
    }
}
